package com.yu.config;

import org.apache.ibatis.transaction.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @Description: TODO
 * @Author : yu
 * Date : 4/27/2020 2:16 PM
 */

public class TransactionConfig implements TransactionManagementConfigurer {
    @Resource
    DataSource dataSource;

    @Override
    public TransactionManager annotationDrivenTransactionManager() {
        //添加一个事务管理器
        //作用：这里没有使用
        return new DataSourceTransactionManager(dataSource);
    }
}
